package com.wn.controller;

import com.wn.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author yellow Docter
 * @date 2022 -07-11
 * @desc
 *
 * 跨域:
 *   01 协议  ip  端口
 *
 *  服务器加注解可以解决跨域问题:
 *    @CrossOrigin :加注解
 *
 */
@CrossOrigin
@Controller
@RequestMapping("user")
public class JsonController2 {

    @ResponseBody
    @RequestMapping("/json1")
    public String json1(User user){

        System.out.println("user " + user);
        return "success";
    }

    @ResponseBody
    @RequestMapping("/json2")
    public String json2(@RequestBody User user){

        System.out.println("user " + user);
        return "success";
    }
}
